#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int* merge(int* nums1, int nums1Size, int* nums2, int nums2Size,int sum) 
{
	int i = 0;
	int j = 0;
	int k = 0;
	int* help = (int*)malloc(sizeof(int) * sum);
	while (i < nums1Size && j < nums2Size)
	{
		if(nums1[i]< nums2[j])
		{ 
			help[k++] = nums1[i++];
		}
		else
		{
			help[k++] = nums2[j++];
		}
	}
	while (i < nums1Size)
	{
		help[k++] = nums1[i++];
	}
	while (j < nums2Size)
	{
		help[k++] = nums2[j++];
	}
	return help;
}
int main()
{
	int arr[] = { 3,5,9 };
	int sz = sizeof(arr) / sizeof(arr[0]);
	int arr1[] = { 1,2,3,5,7 };
	int sz1 = sizeof(arr1) / sizeof(arr1[0]);
	int sz2 = sz + sz1;
	int* p = merge(arr, sz, arr1, sz1,sz2);
	for (int i = 0; i < sz2; i++)
	{
		printf("%d ", p[i]);
	}
	free(p);
	return 0;
}